<% if !@user.nil? %>
  <h1>Account Details for <%= @user.login %></h1>
  <div class="floatrightbox" style="clear: right;">
  <h2>User Info</h2>
  Media: <%= @user.medias.size %><br />
  Media Rated: <%= @user.media_rating_logs.size %><br />
  Comments: <%= @user.comments.size %><br />
  Comments Rated: <%= @user.comment_rating_logs.size %><br />
  Roles: <%= @user.roles.collect{|t| t.name}.join(", ") if @user.roles.size > 0 %><%= "Member" if @user.roles.size < 1 %><br />
  </div>
  <br style="clear: both;" />
  <div id="tabs" class="nicetabs">
    <ul>
      <li><a href="#medias">Media</a></li>
      <li><a href="#comments">Comments</a></li>
    </ul>
  </div>
  <div id="medias">
    <div class="tabbox">
      <div>
        <% for media in @user.medias %>
          <% if media.mediable_type == 'ImageFile' %>
            <div style="width: 210px; height: 250px; padding: 5px; float: left; text-align: center; border: solid 1px #cccccc;">
              <div style="width: 200px; height: 200px;">
                <%= link_to_media_lightbox media.mediable.public_filename(:large), media.mediable.public_filename(:thumb) %>
              </div>
              <%= link_to clean_text(media.title), :controller => 'media', :action => 'show', :id => media.id, :permalink => media.permalink %><br />
              <%= media.user.login %> <%= distance_of_time_in_words_to_now(media.created_at) %> ago<br />
              <% if logged_in? and current_user.has_role?(['Administrator', 'Moderator']) or ( media.user.id == current_user.id and media.deleted_at.nil? ) %>
                (<% if current_user.has_role?(['Administrator', 'Moderator']) %>
        					<%= link_to_component_lightbox 'Edit', { :controller => '/media', :action => 'edit', :id => media.id } %>
  			      		<% if media.deleted_at.nil? or current_user.has_role?(['Administrator', 'Moderator']) %> / <% end %>
        				<% end %>
        				<% if media.deleted_at.nil? %>
                  <%= link_to_component_lightbox 'Delete', { :controller => '/media', :action => 'delete', :id => media.id } %>
        				<% end %>
        				<% if current_user.has_role?(['Administrator', 'Moderator']) and !media.deleted_at.nil? %>
        					<%= link_to 'Undelete', { :controller => '/media', :action => 'undestroy', :id => media.id }, :confirm => 'Are you sure?', :method => :post %> / <%= link_to_component_lightbox 'Show Reason', { :controller => '/media', :action => 'delete_reason', :id => media.id } %>
        				<% end %>)
              <% end %>
          	  <% if !media.deleted_at.nil? %> - Deleted <%= distance_of_time_in_words_to_now(media.deleted_at) %> ago<% end %>
            </div>
          <% else %>
            This is not an image.
          <% end %>
        <% end %>
        <br style="clear: both;" />
      </div>
    </div>
  </div>

  <div id="comments" style="display: none;">
    <div class="tabbox">
      <% for comment in @user.comments %>
        <div>
          <div style="background: #f0f0f0; padding:3px; border: solid 1px #bbbbbb;"> 
            <%= link_to comment.media.title, :controller => 'media', :action => 'show', :id => comment.media.id, :permalink => media.permalink, :anchor => 'comments,'+comment.id.to_s %> by <%= comment.user.login %> <%= distance_of_time_in_words_to_now(comment.created_at) %> ago 
            <% if logged_in? and comment.purged_at.nil? and current_user.has_role?(['Administrator', 'Moderator']) or ( comment.user.id == current_user.id and comment.deleted_at.nil? ) %>
              (<% if current_user.has_role?(['Administrator', 'Moderator']) %>
      					<%= link_to_component_lightbox 'Edit', { :controller => '/comment', :action => 'edit', :id => comment.id } %>
			      		<% if comment.deleted_at.nil? or current_user.has_role?(['Administrator', 'Moderator']) %> / <% end %>
      				<% end %>
      				<% if comment.deleted_at.nil? %>
      					<%= link_to_component_lightbox 'Delete', { :controller => '/comment', :action => 'delete', :id => comment.id } %>
      				<% end %>
      				<% if current_user.has_role?(['Administrator', 'Moderator']) and !comment.deleted_at.nil? %>
      					<%= link_to 'Undelete', { :controller => '/comment', :action => 'undestroy', :id => comment.id }, :confirm => 'Are you sure?', :method => :post %> / <%= link_to_component_lightbox 'Show Reason', { :controller => '/comment', :action => 'delete_reason', :id => comment.id } %>
      				<% end %>)
            <% end %>
        	  <% if !comment.deleted_at.nil? %> - Deleted <%= distance_of_time_in_words_to_now(comment.deleted_at) %> ago<% end %>
        	  <% if !comment.purged_at.nil? %> - Purged <%= distance_of_time_in_words_to_now(comment.deleted_at) %> ago<% end %>
          </div>
          <div style="clear: both; padding: 5px;">
            <%= format_text(comment.text[0,200]) %>
          </div>
        </div>
      <% end %>
    </div>
  </div>
  <script>
    tabs = new Control.Tabs('tabs');
  </script>
<% else %>
  <h2>User not found: <%= params[:id] %></h2>
<% end %>